package xyz.erupt.jpa.model;

import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.ColumnDefault;
import xyz.erupt.annotation.EruptField;
import xyz.erupt.annotation.PreDataProxy;
import xyz.erupt.annotation.config.EruptSmartSkipSerialize;
import xyz.erupt.annotation.sub_field.Edit;
import xyz.erupt.annotation.sub_field.EditType;
import xyz.erupt.annotation.sub_field.View;
import xyz.erupt.annotation.sub_field.ViewType;
import xyz.erupt.annotation.sub_field.sub_edit.DateType;

import javax.persistence.MappedSuperclass;
import java.time.LocalDateTime;

/**
 * 带逻辑删除标志的删除对象<br/>
 *
 * @author Ajian
 * @date 2022-08-05 00:52
 */
@Getter
@Setter
@PreDataProxy(SoftDelModelProxy.class)
@MappedSuperclass //作用 jpa 父类标识注解
public class SoftDelModel extends MetaModel {

    @EruptField(
            views = @View(title = "是否删除", show = false, type = ViewType.BOOLEAN),
            edit = @Edit(title = "是否删除", show = false, type = EditType.BOOLEAN)
    )
    @EruptSmartSkipSerialize //作用：让子类也可定义同名字段，提升字段复用性
    @ColumnDefault("0")
    private Boolean delFlag = false;

    @EruptField(
            views = @View(title = "删除人", show = false),
            edit = @Edit(title = "删除人", show = false)
    )
    @EruptSmartSkipSerialize
    private String delOperatorAccount;

    @EruptField(
            views = @View(title = "删除时间", show = false),
            edit = @Edit(title = "删除时间", show = false, dateType = @DateType(type = DateType.Type.DATE_TIME))
    )
    @EruptSmartSkipSerialize
    private LocalDateTime delTime;
}
